<form action="index.php?app=ome&ctl=admin_goods_type&act=save" method="post" id='type_form' >
    <h5 class="head-title"><{t}>新建/编辑物料类型<{/t}></h5>
    <input type="hidden" name="gtype[type_id]" value=<{$gtype.type_id}>>

    <div class="tableform tableform-tabs">
        <{tabber}>
        <div class="division" style="padding:5px; border:1px solid #dddddd; margin:1px 5px;">
            <{tab name="基本设置"}>
            <input type='hidden' name='gtype[is_physical]' value='<{$gtype.is_physical|default:1}>'/>
            <input type='hidden' name='gtype[setting][use_brand]' value='<{$gtype.setting.use_brand}>'/>

            <{include file="admin/goods/goods_type/form_edit_name.html"}>
            <{/tab}>
            <{if $gtype.setting.use_props}>
            <input type='hidden' name='gtype[setting][use_props]' value='1'/>
            <{tab name="扩展属性"}>
            <{include file="admin/goods/goods_type/form_edit_props.html"}>
            <{/tab}>
            <{/if}>

            <{if $gtype.setting.use_params}>
            <input type='hidden' name='gtype[setting][use_params]' value='1'/>
            <{tab name="详细参数表"}>
            <{include file="admin/goods/goods_type/form_edit_params.html"}>
            <{/tab}>
            <{/if}>
            <{if $gtype.setting.use_minfo}>
            <input type='hidden' name='gtype[setting][use_minfo]' value='1'/>
            <{tab name="购物必填信息"}>
            <{include file="admin/goods/goods_type/form_edit_minfo.html"}>
            <{/tab}>
            <{/if}>
        </div>
        <{/tabber}>
    </div>

    <div class="table-action">
        <{button type="button"  label="保存" id='type_submit'}>
    </div>
</form>
<script>
    (function(){
        $('type_form').store('target',{
            onRequest:function(){
                $('type_submit').set('disabled', 'true');
            },
            onComplete:function(jsontext){
                var json = Json.evaluate(jsontext);
                if (typeof(json.error) != 'undefined'){
                    $('type_submit').set('disabled', '');
                }else{
                    $('type_submit').set('disabled', 'true');
                    opener.finderGroup['<{$env.get.finder_id}>'].refresh.delay(400,opener.finderGroup['<{$env.get.finder_id}>']);
                    window.close();
                }
            }
        });

        $('type_submit').addEvent('click',function(){
            //类型名称不能为空
            var type_name = $E('#type_form input[name^=gtype[name]').get('value');
            if (!type_name){
                alert('类型名称不能为空！');
                return false;
            }
            new Request({url:'index.php?app=ome&ctl=admin_goods_type&act=check_type',method:'post',data:'id='+$E('#type_form input[name^=gtype[type_id]').get('value')+'&name='+$E('#type_form input[name^=gtype[name]').get('value'),
                onComplete:function(e){
                    if(e == 'false')
                        alert('类型名称已存在');
                    else
                        $('type_form').fireEvent('submit',{stop:$empty});
                }
            }).send();
        });
    })();
</script>
